using System;
namespace Net35.Xrm.Sdk
{
	[AttributeUsage(AttributeTargets.Property)]
	public sealed class RelationshipSchemaNameAttribute : Attribute
	{
		private readonly Relationship _relationship;
		public string SchemaName
		{
			get
			{
				return this._relationship.SchemaName;
			}
		}
		public EntityRole? PrimaryEntityRole
		{
			get
			{
				return this._relationship.PrimaryEntityRole;
			}
		}
		internal Relationship Relationship
		{
			get
			{
				return this._relationship;
			}
		}
		public RelationshipSchemaNameAttribute(string schemaName) : this(schemaName, null)
		{
		}
		public RelationshipSchemaNameAttribute(string schemaName, EntityRole primaryEntityRole) : this(schemaName, new EntityRole?(primaryEntityRole))
		{
		}
		private RelationshipSchemaNameAttribute(string schemaName, EntityRole? primaryEntityRole)
		{
			if (StringExtensions.IsNullOrWhiteSpace(schemaName))
			{
				throw new ArgumentNullException("schemaName");
			}
			this._relationship = new Relationship(schemaName);
			this._relationship.PrimaryEntityRole = primaryEntityRole;
		}
	}
}
